# ~/.bashrc
#
# This file is part of bashrc.x.
#
# bashrc.x is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# bashrc.x is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with bashrc.x.  If not, see <http://www.gnu.org/licenses/>.
#
# @package   bashrc.x
# @author    Snakevil Zen <zsnakevil@gmail.com>
# @copyright © 2012 szen.in
# @license   http://www.gnu.org/licenses/gpl.html

declare -Ax BASHRCX_BINS
declare -Ax BASHRCX_COLORS
declare -Ax BASHRCX_OPTS
declare -Ax BASHRCX_VARS

BASHRCX_VARS['checkpoint']=`'date' +'%s.%N'`

[ -n "$BASH" ] || return

[ -n "$PS1" ] || return

export HISTCONTROL="ignoreboth"
export HISTFILESIZE=840806
export HISTIGNORE="ls:fg:ll:la"
export HISTSIZE=2012
export HISTTIMEFORMAT="%F %T "

shopt -s histappend

set -o functrace
shopt -s extdebug

shopt -u sourcepath

function _bashrc.x-which {
  local ii
  for ii; do
    [ -n "${BASHRCX_BINS[$ii]}" ] || {
      BASHRCX_BINS[$ii]=`'which' "$ii"`
      [ 0 -eq $? ] || BASHRCX_BINS[$ii]="$ii"
    }
    [ "s$ii" != "s${BASHRCX_BINS[$ii]}" ] || return 1
  done
}

function _bashrc.x-main {
  local aa bb cc dd ee ff gg
  local hh ii jj kk ll mm nn
  local oo pp qq rr ss tt
  local uu vv ww xx yy zz
  _bashrc.x-which 'basename' 'cut' 'sort' || return
  for ii in $(for ii in ~/.local/bashrc.x/etc/bashrc.d/[0-9][0-9]-*.sh \
      ~/.bashrc.x/bashrc.d/[0-9][0-9]-*.sh; do
      [ ! -r "$ii" ] || {
        printf "%-256s" `'basename' "$ii"`
        echo "$ii"
      }
    done | 'sort' -k'1,1' -k'2r' | 'cut' -b'257-'); do
    source "$ii"
  done
} 3>&2 > /dev/null 2>&1
_bashrc.x-main
unset -f _bashrc.x-main _bashrc.x-which

# vim: se ft=sh ff=unix fenc=utf-8 sw=2 ts=2 sts=2:
